package com.kkd.kkdapp.adapter;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.activity.ExperienceParticularsActivity;
import com.kkd.kkdapp.activity.ForTenderActivity;
import com.kkd.kkdapp.activity.LoginActivity;
import com.kkd.kkdapp.activity.RegularParticularsActivity;
import com.kkd.kkdapp.activity.TenderAffirmActivity;
import com.kkd.kkdapp.http.entity.HomeTender;
import com.kkd.kkdapp.http.manager.HttpCallBack;
import com.kkd.kkdapp.http.manager.KkdHttpMagager;
import com.kkd.kkdapp.listener.OnSingleClickListener;
import com.kkd.kkdapp.utils.AppUtil;
import com.kkd.kkdapp.utils.PreferenceUtils;
import com.kkd.kkdapp.utils.SystemUtils;
import com.kkd.kkdapp.utils.Tools;
import com.kkd.kkdapp.view.RoundProgressBar;
import com.kkd.kkdapp.view.shapeimageview.PorterShapeImageView;
import com.umeng.message.PushAgent;
import com.umeng.message.local.UmengLocalNotification;
import com.umeng.message.local.UmengNotificationBuilder;

public class WelfareAdapter extends BaseAdapter {

	private Context mContext;
	private LayoutInflater inflater;
	private List<HomeTender> datalist;
	private double balance;
	private Toast mToast;

	public WelfareAdapter(Context context, List<HomeTender> datalist) {
		this.mContext = context;
		inflater = LayoutInflater.from(context);
		this.datalist = datalist;
	}

	@Override
	public int getCount() {
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		return datalist.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder mViewHolder;
		if (convertView == null) {
			convertView = inflater
					.inflate(R.layout.welfare_bid_list_item, null);
			mViewHolder = new ViewHolder();
			// 上部点击进入标的详情界面
			mViewHolder.top = (RelativeLayout) convertView
					.findViewById(R.id.top);
			// 标题
			mViewHolder.refund_name = (TextView) convertView
					.findViewById(R.id.refund_name);
			// 标的类型
			mViewHolder.type_bg = (PorterShapeImageView) convertView
					.findViewById(R.id.type_bg);
			mViewHolder.type_tv = (TextView) convertView
					.findViewById(R.id.type_tv);

			// 年利率
			mViewHolder.interest_tv = (TextView) convertView
					.findViewById(R.id.interest_tv);
			// 加息
			mViewHolder.rise_tv1 = (TextView) convertView
					.findViewById(R.id.rise_tv1);

			// 理财期限
			mViewHolder.deadline_tv = (TextView) convertView
					.findViewById(R.id.deadline_tv);
			// 理财期限单位
			mViewHolder.deadline_company_tv = (TextView) convertView
					.findViewById(R.id.deadline_company_tv);
			// 按钮
			mViewHolder.bid = (LinearLayout) convertView.findViewById(R.id.bid);
			mViewHolder.progressBar = (RoundProgressBar) convertView
					.findViewById(R.id.progressBar1);
			mViewHolder.bid_tv1 = (TextView) convertView
					.findViewById(R.id.bid_tv1);
			mViewHolder.bid_tv2 = (TextView) convertView
					.findViewById(R.id.bid_tv2);

			mViewHolder.zhanqi_count = (TextView) convertView
					.findViewById(R.id.zhanqi_count);

			mViewHolder.tuijian = (ImageView) convertView
					.findViewById(R.id.tuijian);
			convertView.setTag(mViewHolder);

		} else {
			mViewHolder = (ViewHolder) convertView.getTag();
		}
		renderBidView(position, mViewHolder);
		return convertView;
	}

	/**
	 * gotoOldLogic:(这里用一句话描述这个方法的作用). <br/>
	 * 
	 * @author askzhao
	 */
	private void renderBidView(final int position, ViewHolder mViewHolder) {

		if (datalist.get(position).getIsRecommend() == 0) {
			mViewHolder.tuijian.setBackgroundColor(Color.parseColor(datalist
					.get(position).getBidTypeColor()));
			LayoutParams params = mViewHolder.tuijian.getLayoutParams();
			params.width = SystemUtils.dip2px(mContext, 4);
			params.height = SystemUtils.dip2px(mContext, 14);
			mViewHolder.tuijian.setLayoutParams(params);

		} else {
			mViewHolder.tuijian.setBackgroundResource(R.drawable.tuijian);
			LayoutParams params = mViewHolder.tuijian.getLayoutParams();
			params.width = LayoutParams.WRAP_CONTENT;
			params.height = LayoutParams.WRAP_CONTENT;
			mViewHolder.tuijian.setLayoutParams(params);
		}
		/*************** 标题 *****************/
		mViewHolder.refund_name.setTag(position);
		mViewHolder.refund_name.setText(datalist.get(position).getBidTitle());
		/*************** 标的类型 **************/
		mViewHolder.type_bg.setTag(position);
		mViewHolder.type_tv.setTag(position);
		if (TextUtils.isEmpty(datalist.get(position).getDealDesc())) {
			mViewHolder.type_tv.setVisibility(View.INVISIBLE);
			mViewHolder.type_bg.setVisibility(View.INVISIBLE);
		} else {
			mViewHolder.type_tv.setVisibility(View.VISIBLE);
			mViewHolder.type_bg.setVisibility(View.VISIBLE);
			mViewHolder.type_tv.setText(datalist.get(position).getDealDesc());
			mViewHolder.type_tv.setTextColor(Color.parseColor(datalist.get(
					position).getBidTypeColor3()));
			mViewHolder.type_bg.setImageColor(Color.parseColor(datalist.get(
					position).getBidTypeColor3()));

			LayoutParams params = mViewHolder.type_bg.getLayoutParams();
			params.width = SystemUtils.dip2px(mContext,
					11 * datalist.get(position).getDealDesc().length() + 12);
			mViewHolder.type_bg.setLayoutParams(params);
		}

		/**************** 年利率 **************/
		mViewHolder.interest_tv.setTag(position);
		mViewHolder.rise_tv1.setTag(position);
		String interestDisplay = datalist.get(position).getInterestDisplay();
		mViewHolder.interest_tv.setText(interestDisplay);
		if (interestDisplay.indexOf("+") == -1) {
			mViewHolder.interest_tv.setText(Tools.intOrDouble(Double
					.parseDouble(interestDisplay)));
			mViewHolder.rise_tv1.setText("");
		} else {
			String[] idp = interestDisplay.split("\\+");
			mViewHolder.interest_tv.setText(Tools.intOrDouble(Double
					.parseDouble(idp[0])));
			mViewHolder.rise_tv1.setText("+"
					+ Tools.intOrDouble(Double.parseDouble(idp[1])) + "%");
		}

		/*************** 标的期限 *****************/
		mViewHolder.deadline_tv.setTag(position);
		mViewHolder.deadline_tv.setText(datalist.get(position).getBidPeriod()
				+ "");
		/*************** 标的期限单位 ******************/
		String bidPeriodType = datalist.get(position).getBidPeriodType();
		if ("月".equals(bidPeriodType)) {
			mViewHolder.deadline_company_tv.setText("个" + bidPeriodType);
		} else if ("天".equals(bidPeriodType)) {
			mViewHolder.deadline_company_tv.setText(bidPeriodType);
		}
		String bidPeriodWeb = datalist.get(position).getBidPeriodWeb();
		int p = bidPeriodWeb.indexOf("+");
		if (p > 0) {
			mViewHolder.zhanqi_count.setVisibility(View.VISIBLE);
			String bidPeriodType2 = bidPeriodWeb.substring(p);
			mViewHolder.zhanqi_count.setText(bidPeriodType2);
		} else {
			mViewHolder.zhanqi_count.setVisibility(View.GONE);
		}

		/***************** 标的状态 *******************/
		int bidAmout = (int) (datalist.get(position).getBidAmount() / 100);
		double bidFreeAmount = datalist.get(position).getBidFreeAmount() * 0.01;
		int interest = (int) Math.ceil((1 - bidFreeAmount / bidAmout) * 100);
		mViewHolder.progressBar.setRoundWidth(SystemUtils.dip2px(mContext, 3));
		// 进度色值
		mViewHolder.progressBar.setCricleProgressColor(0xffff5a00);
		// 圆环色值
		mViewHolder.progressBar.setCricleColor(0xfff4f4f4);
		mViewHolder.progressBar.setProgress(interest == 0 ? 1 : interest);
		mViewHolder.progressBar.setTag(position);
		mViewHolder.progressBar.setVisibility(View.GONE);

		mViewHolder.bid.setTag(position);
		mViewHolder.bid.setBackgroundResource(R.drawable.tender_bt_selector);
		mViewHolder.bid.setVisibility(View.VISIBLE);
		mViewHolder.bid.setEnabled(true);
		mViewHolder.bid.setClickable(true);
		mViewHolder.bid_tv1.setVisibility(View.GONE);
		mViewHolder.bid_tv2.setVisibility(View.GONE);

		String bidStatus = datalist.get(position).getBidStatus();
		if ("5002".equals(bidStatus)) {// 可投标状态或倒计时状态

			if (datalist.get(position).getCountDown() > 0) {

				if (!isRecoding) {
					startCountdown();
				}
				mViewHolder.progressBar.setVisibility(View.GONE);
				mViewHolder.bid
						.setBackgroundResource(R.drawable.tender_img_countdown);
				mViewHolder.bid.setEnabled(false);
				mViewHolder.bid.setClickable(false);
				int time = (int) datalist.get(position).getCountDown() / 1000;
				int min = time / 60;
				int sec = time % 60;
				String text = String.format("%02d:%02d", min, sec);
				mViewHolder.bid_tv1.setVisibility(View.VISIBLE);
				mViewHolder.bid_tv2.setVisibility(View.VISIBLE);
				mViewHolder.bid_tv1.setText(text);
				mViewHolder.bid_tv2.setText("后抢购");
			} else {
				mViewHolder.progressBar.setVisibility(View.VISIBLE);
				mViewHolder.bid
						.setBackgroundResource(R.drawable.tender_img_tou);
			}

			mViewHolder.bid.setOnClickListener(new OnSingleClickListener() {

				@Override
				public void onSingleClick(View v) {

					SystemUtils.onEvent("Regular_Bid", 1);

					try {
						if (datalist.get(position).getCountDown() <= 0) {

							if (PreferenceUtils.getInstance()
									.getLogin(mContext) == 0) { // 登陆验证

								if (PreferenceUtils.getInstance().getAutonym(
										mContext) == 1) { // 身份认证

									if (PreferenceUtils.getInstance()
											.getBoundBankCard(mContext) == 1) { // 判定银行卡是否绑定
										gotoTenderActivity(datalist
												.get(position));
									} else {
										getAccountInfo(datalist.get(position));

									}

								} else {
									gotoTrueIDVerifyActivity(datalist
											.get(position));

								}

							} else {

								Intent intent = new Intent(mContext,
										LoginActivity.class);
								mContext.startActivity(intent);

							}

						}

					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			});
		} else if ("5003".equals(bidStatus)) {// 已满标
			mViewHolder.bid.setBackgroundResource(R.drawable.tender_img_man);
			mViewHolder.bid.setClickable(false);
		} else if ("5004".equals(bidStatus)) {// 还款中
			mViewHolder.bid
					.setBackgroundResource(R.drawable.tender_img_returning);
			mViewHolder.bid.setClickable(false);
		} else if ("5005".equals(bidStatus)) {// 已还款
			mViewHolder.bid.setClickable(false);
			mViewHolder.bid.setBackgroundResource(R.drawable.tender_img_returnd);
		}else {
			mViewHolder.bid.setVisibility(View.GONE);
			mViewHolder.bid.setEnabled(false);
			mViewHolder.bid.setClickable(false);
		}

		mViewHolder.top.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (!datalist.get(position).getBidType().endsWith("501")) {
					SystemUtils.onEvent("Regular_Detail", 1);
				} else {
					SystemUtils.onEvent("Experience_Detail", 1);
				}
				try {
					String bidType = datalist.get(position).getBidType();
					if ("501".equals(bidType)) {
						Intent intent = new Intent(mContext,
								ExperienceParticularsActivity.class);
						intent.putExtra("bidId", datalist.get(position)
								.getBidId());
						intent.putExtra("bidType", datalist.get(position)
								.getBidType());
						intent.putExtra("appbiddetail", datalist.get(position)
								.getAppbiddetail());
						mContext.startActivity(intent);
					} else {
						Intent intent = new Intent(mContext,
								RegularParticularsActivity.class);
						intent.putExtra("bidId", datalist.get(position)
								.getBidId());
						intent.putExtra("bidType", datalist.get(position)
								.getBidType());
						intent.putExtra("appbiddetail", datalist.get(position)
								.getAppbiddetail());
						mContext.startActivity(intent);
					}
				} catch (Exception e) {
					e.printStackTrace();
				}

			}
		});

	}

	public void gotoTenderActivity(HomeTender tenderData) {
		Intent intent = new Intent(mContext, TenderAffirmActivity.class);
		intent.putExtra("bidId", tenderData.getBidId());
		intent.putExtra("bidTitle", tenderData.getBidTitle());
		intent.putExtra("bidPeriod", tenderData.getBidPeriod());
		intent.putExtra("amountMultiple", tenderData.getAmountMultiple());
		intent.putExtra("lowestAmount", tenderData.getLowestAmount());
		intent.putExtra("bidPeriodType", tenderData.getBidPeriodType());
		intent.putExtra("bidInterest", tenderData.getInterestDisplay());
		intent.putExtra("bidFreeAmount", tenderData.getBidFreeAmount());
		intent.putExtra("maxAmount", tenderData.getMaxAmount());
		intent.putExtra("bidAmount", tenderData.getBidAmount());
		intent.putExtra("totalLixi", tenderData.getTotalLixi());
		intent.putExtra("bidType", tenderData.getBidType());
		intent.putExtra("productType", tenderData.getProductType());
		intent.putExtra("bidPeriodAdd", tenderData.getBidPeriodAdd());
		intent.putExtra("isNewbie", tenderData.getIsNewbie());
		if (tenderData.getProductType() == 3) {
			intent.putExtra("businessType", "3");
		} else {
			intent.putExtra("businessType", "1");
		}// 区分信用标还是抵押标
		intent.putExtra("bidPeriodWeb", tenderData.getBidPeriodWeb());
		if ("501".equals(tenderData.getBidType())) {// 为体验标
			//并且没有快快享福特权
			if(PreferenceUtils.getInstance().getKkxfStatus(mContext) == 0){
				AppUtil.makeToastForCustomer(mContext, PreferenceUtils
						.getInstance().getKkxfExt(mContext));
			}else{
				if(tenderData.getCountDown()<=0){
					mContext.startActivity(intent);
				}else{
					registerNotification(tenderData.getCountDown(), tenderData.getBidTitle());
					showToast("将在开标前3分钟通过推送消息通知您");
				}
				
			}
			
		} else {
			mContext.startActivity(intent);
		}
	}

	public void gotoTrueIDVerifyActivity(HomeTender tenderData) {
		Intent intent = new Intent(mContext, ForTenderActivity.class);
		intent.putExtra("enterTypeFlag", 5);
		intent.putExtra("bidId", tenderData.getBidId());
		intent.putExtra("bidTitle", tenderData.getBidTitle());
		intent.putExtra("bidPeriod", tenderData.getBidPeriod());
		intent.putExtra("amountMultiple", tenderData.getAmountMultiple());
		intent.putExtra("lowestAmount", tenderData.getLowestAmount());
		intent.putExtra("bidPeriodType", tenderData.getBidPeriodType());
		intent.putExtra("bidInterest", tenderData.getInterestDisplay());
		intent.putExtra("bidFreeAmount", tenderData.getBidFreeAmount());
		intent.putExtra("maxAmount", tenderData.getMaxAmount());
		intent.putExtra("bidAmount", tenderData.getBidAmount());
		intent.putExtra("totalLixi", tenderData.getTotalLixi());
		intent.putExtra("productType", tenderData.getProductType());
		intent.putExtra("bidPeriodAdd", tenderData.getBidPeriodAdd());
		intent.putExtra("isNewbie", tenderData.getIsNewbie());

		if (tenderData.getProductType() == 3) {
			intent.putExtra("businessType", "3");
		} else {
			intent.putExtra("businessType", "1");
		}
		intent.putExtra("bidPeriodWeb", tenderData.getBidPeriodWeb());
		mContext.startActivity(intent);
	}

	public void gotoAddBankActivity(HomeTender tenderData) {
		Intent intent = new Intent(mContext, ForTenderActivity.class);
		intent.putExtra("enterTypeFlag", 5);
		intent.putExtra("bidType", tenderData.getBidType());
		intent.putExtra("bidId", tenderData.getBidId());
		intent.putExtra("bidTitle", tenderData.getBidTitle());
		intent.putExtra("bidPeriod", tenderData.getBidPeriod());
		intent.putExtra("amountMultiple", tenderData.getAmountMultiple());
		intent.putExtra("lowestAmount", tenderData.getLowestAmount());
		intent.putExtra("bidPeriodType", tenderData.getBidPeriodType());
		intent.putExtra("bidInterest", tenderData.getBidInterest());
		intent.putExtra("bidFreeAmount", tenderData.getBidFreeAmount());
		intent.putExtra("maxAmount", tenderData.getMaxAmount());
		intent.putExtra("bidInterest", tenderData.getInterestDisplay());
		intent.putExtra("bidAmount", tenderData.getBidAmount());
		intent.putExtra("totalLixi", tenderData.getTotalLixi());
		intent.putExtra("productType", tenderData.getProductType());
		intent.putExtra("bidPeriodAdd", tenderData.getBidPeriodAdd());
		intent.putExtra("isNewbie", tenderData.getIsNewbie());
		if (tenderData.getProductType() == 3) {
			intent.putExtra("businessType", "3");
		} else {
			intent.putExtra("businessType", "1");
		}
		intent.putExtra("bidPeriodWeb", tenderData.getBidPeriodWeb());
		mContext.startActivity(intent);
	}

	/**
	 * 
	 * 查询账户余额
	 */
	public void getAccountInfo(final HomeTender tenderData) {

		KkdHttpMagager.getInstance().getAccountInfoManager(
				String.class, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						try {
							String responseString = responseBody.toString();
							JSONObject data = new JSONObject(responseString);
							balance = data.getDouble("balance");
							if (balance == 0) {
								gotoAddBankActivity(tenderData);

							} else {
								gotoTenderActivity(tenderData);
							}

						} catch (JSONException e) {
							e.printStackTrace();
						}
					}

					@Override
					public void onFailure(int statusCode, String desc) {
						showToast(desc);
					}
				});
	}

	public void showToast(String hintLanguage) {
		if (mToast != null) {
			mToast.cancel();
			mToast = null;
		}
		mToast = Toast.makeText(mContext, hintLanguage, Toast.LENGTH_SHORT);
		mToast.show();
	}

	public void showToast(int hintLanguage) {
		if (mToast != null) {
			mToast.cancel();
			mToast = null;
		}
		mToast = Toast.makeText(mContext, hintLanguage, Toast.LENGTH_SHORT);
		mToast.show();
	}

	private class ViewHolder {
		RelativeLayout top;
		TextView refund_name;
		TextView interest_tv;
		TextView deadline_tv;
		TextView zhanqi_count;
		LinearLayout bid;
		TextView bid_tv1;
		TextView bid_tv2;
		PorterShapeImageView type_bg;
		RoundProgressBar progressBar;
		TextView type_tv;
		TextView deadline_company_tv;
		TextView rise_tv1;
		ImageView tuijian;
	}

	public static final int PERIOD = 1000;
	public static final int RECORD_TIMER = 8112;
	public static final int RECORD_DONE = 8113;
	public static final int RECORD_ERROR = 8114;
	private boolean isRecoding = false;
	private Timer mTimer = null;
	private TimerTask mTimerTask = null;

	private void startCountdown() {
		if (mTimerTask == null) {
			mTimerTask = new RecordTimeTask();

		}
		if (mTimer == null) {
			mTimer = new Timer();

		}
		mTimer.schedule(mTimerTask, 0, PERIOD);
		isRecoding = true;

	}

	private void shutCountdown() {
		if (mTimer != null) {
			mTimer.cancel();
			mTimer = null;
		}
		if (mTimerTask != null) {
			mTimerTask.cancel();
			mTimerTask = null;
		}
		isRecoding = false;

	}

	public TimerHandler mTimerHandler = new TimerHandler(this);

	public static class TimerHandler extends Handler {
		WeakReference<WelfareAdapter> reference;

		public TimerHandler(WelfareAdapter view) {
			reference = new WeakReference<WelfareAdapter>(view);
		}

		@Override
		public void dispatchMessage(Message msg) {
			switch (msg.what) {
			case RECORD_TIMER:
				if (reference != null && reference.get() != null) {
					// reference.get().updatePurchaseBtn();
					try {
						boolean shut_down = true;
						for (HomeTender ht : reference.get().datalist) {
							if (ht.getCountDown() > 0) {
								ht.setCountDown(ht.getCountDown() - 1000 > 0 ? ht
										.getCountDown() - 1000 : 0);
								shut_down = false;
							}
						}
						reference.get().notifyDataSetChanged();
						if (shut_down)
							sendEmptyMessage(RECORD_DONE);
					} catch (Exception e) {
					}

				}
				break;
			case RECORD_DONE:
				if (reference != null && reference.get() != null) {
					reference.get().shutCountdown();
				}
				break;
			default:
				break;
			}
		}
	}

	private class RecordTimeTask extends TimerTask {
		@Override
		public void run() {
			if (isRecoding) {
				Message message = new Message();
				message.what = RECORD_TIMER;
				mTimerHandler.sendMessage(message);
			}

		}
	}
	
	// 注册通知
		public void registerNotification(long coutDown, String title) {

			// 开发者可以自定义本地通知
			UmengLocalNotification localNotification = new UmengLocalNotification();

			// 自定义本地通知相关属性：
			localNotification.setTitle(title + "马上开标啦。"); // 设置通知标题
			localNotification.setContent("赶紧登录快快贷来抢吧。"); // 设置通知内容

			Date nowTime = new Date(System.currentTimeMillis() + coutDown - 1000
					* 60 * 3);
			SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			localNotification.setTicker(title + "马上开标啦，赶紧登录快快贷来抢吧。"); // 设置通知提示
			localNotification.setDateTime(time.format(nowTime)); // 设置通知开始时间
			// localNotification.setLunarDateTime(String dateTime); //设置通知开始的阴历时间
			// localNotification.setSpecialDay(int specialDay); //设置通知节日
			// localNotification.setRepeatingNum(int repeatingNum); //设置通知重复数，默认是1
			// localNotification.setRepeatingInterval(int repeatingInterval);
			// //设置通知重复间隔，默认是1
			// localNotification.setRepeatingUnit(int repeatingUnit); //设置通知重复单位

			// 开发者可以自定义本地通知样式
			UmengNotificationBuilder notificationBuilder = localNotification
					.getNotificationBuilder();

			// 针对通知通用属性的设置:
			// notificationBuilder.setDefaults(int defaults); //设置Defaults
			// notificationBuilder.setFlags(int flags); //设置Flags
			// notificationBuilder.setSmallIconDrawable(""); //设置小图标
			// notificationBuilder.setLargeIconDrawable(String drawable); //设置大图标
			// notificationBuilder.setSoundDrawable(String drawable); //设置声音
			notificationBuilder.setPlayVibrate(true); // 设置振动
			// notificationBuilder.setPlayLights(boolean lights); //设置呼吸灯
			notificationBuilder.setPlaySound(true); // 设置声响
			notificationBuilder.setScreenOn(true); // 设置屏显

			// 针对通知自定义样式的设置：
			// notificationBuilder.setLayoutId(int layoutId); //设置自定义样式Id
			// notificationBuilder.setLayoutTitleId(int layoutTitleId); //设置自定义标题Id
			// notificationBuilder.setLayoutContentId(int layoutContentId);
			// //设置自定义内容Id
			// notificationBuilder.setLayoutIconId(int layoutIconId); //设置自定义小图标Id
			// notificationBuilder.setLayoutIconDrawableId(int
			// layoutIconDrawableId); //设置自定义大图标Id

			// 注意：自定义样式的5个参数都必须设置，否则通知自定义样式会无法展示。

			// 为本地通知设置自定义通知样式
			localNotification.setNotificationBuilder(notificationBuilder);
			PushAgent mPushAgent = PushAgent.getInstance(mContext);
			mPushAgent.addLocalNotification(localNotification);

		}

}
